package com.neusoft.elmboot.po;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class User implements UserDetails {

	private String source;// 登录来源（pc: 电脑登录 ；mobile：手机登录）
	private String code;//验证码

	private Integer id; // 自增长主键
	private String userId; // 用户手机号（唯一的）
	private String password;
	private String userName;
	private Integer userSex;
	private String userImg;
	private Integer del;
	private Date createTime;
	private Date updateTime;
	//实现UserDetails接口需要用到的字段：
	private boolean isexpired; //
	private boolean isenable;
	private boolean islock;
	private Boolean iscredentials = false;
	// 用户权限集合
	private List<GrantedAuthority> authorities;


	public String getUserName() {
		return this.userName;
	}

	@Override
	public String getUsername() {
		return userId;
	}

	@Override
	public boolean isAccountNonExpired() {
		return isexpired;
	}

	@Override
	public boolean isAccountNonLocked() {
		return islock;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return iscredentials;
	}

	@Override
	public boolean isEnabled() {
		return isenable;
	}
}